﻿using AutoMapper;
using Pay.Core;
using Pay.Data;
using Pay.DTO;
using Pay.IService;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Pay.Service.AutoMapper {
   
    public class TokenUpGradeMapper : IStartupDto {
        private IMapperConfigurationExpression _cfg;
        public TokenUpGradeMapper(IMapperConfigurationExpression cfg) {
            _cfg = cfg;
        }
        public void Execute() {
            Create();
        }
        protected virtual void Create() {
            _cfg.CreateMap<TokenUpGrade, token_up_grade_dto>()
                .ForMember(dest => dest.id, src => src.MapFrom(c => c.Id))
                .ForMember(dest => dest.merchant_id, src => src.MapFrom(c => c.MerchantId))
                .ForMember(dest => dest.merchant_name, src => src.MapFrom(c => c.MerchantName))
                .ForMember(dest => dest.mobile, src => src.MapFrom(c => c.Merchant.Mobile))
                 .ForMember(dest => dest.amount, src => src.MapFrom(c => c.Amount))
                 .ForMember(dest => dest.transfer_voucher, src => src.MapFrom(c => c.TransferVoucher))
                .ForMember(dest => dest.grade, src => src.MapFrom(c => c.GradeId))
                .ForMember(dest => dest.grade_des, src => src.MapFrom(c => c.GradeId.ToDescription()))
                .ForMember(dest => dest.apply_time, src => src.MapFrom(c => c.ApplyTime.ToDateTime()))
                .ForMember(dest => dest.audit_time, src => src.MapFrom(c => c.AuditTime.ToDateTime()))
                .ForMember(dest => dest.apply_mobile, src => src.MapFrom(c => c.ApplyMerchant.Mobile))
                .ForMember(dest => dest.apply_merchant_id, src => src.MapFrom(c => c.ApplyMerchantId))
                .ForMember(dest => dest.city_company_merchant_id, src => src.MapFrom(c => c.CityCompanyMerchantId))
                .ForMember(dest => dest.city_company_mobile, src => src.MapFrom(c => c.CityCompanyMerchant.Mobile))
                .ForMember(dest => dest.e_up_grade_audit, src => src.MapFrom(c =>c.EUpGradeAudit))
                 .ForMember(dest => dest.e_up_grade_audit_desc, src => src.MapFrom(c => c.EUpGradeAudit.ToDescription()));



            _cfg.CreateMap<token_up_grade_dto, TokenUpGrade>()
                  .ForMember(dest => dest.Id, src => src.MapFrom(c => c.id))
                  .ForMember(dest => dest.MerchantId, src => src.MapFrom(c => c.merchant_id))
                  .ForMember(dest => dest.MerchantName, src => src.MapFrom(c => c.merchant_name))
                  .ForMember(dest => dest.ApplyMerchantId, src => src.MapFrom(c => c.apply_merchant_id))
                  .ForMember(dest => dest.Amount, src => src.MapFrom(c => c.amount))
                     .ForMember(dest => dest.TransferVoucher, src => src.MapFrom(c => c.transfer_voucher))
                  .ForMember(dest => dest.ApplyTime, src => src.MapFrom(c => c.apply_time.ToUnix()))
                   .ForMember(dest => dest.AuditTime, src => src.MapFrom(c => c.audit_time.ToUnix()))
                   .ForMember(dest => dest.CityCompanyMerchantId, src => src.MapFrom(c => c.city_company_merchant_id))
                    .ForMember(dest => dest.EUpGradeAudit, src => src.MapFrom(c => c.e_up_grade_audit))
                  .ForMember(dest => dest.GradeId, src => src.MapFrom(c => c.grade));


        }
    }
}
